package com.example.bbs.web.servlet; /**
 * @auther: zhangxin
 * @Description:
 */

import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.example.bbs.dao.BaseDao;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.sql.DataSource;
import java.util.Properties;

@WebServlet(name = "InitServlet", value = "/InitServlet",loadOnStartup = 0)
public class InitServlet extends HttpServlet {

    public void init(){

        Properties prop = new Properties();
        try {
            prop.load(InitServlet.class.getResourceAsStream("/druid.properties"));
            DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
            System.out.println(dataSource.getConnection());
            BaseDao.init(dataSource);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
